/*
 Copyright (C) 2008  Maurizio Monticelli

 This program is free software; you can redistribute it and/or modify it under the terms of the 
 GNU General Public License as published by the Free Software Foundation; either version 2 of the 
 License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
 even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 
 Public License for more details.

 You should have received a copy of the GNU General Public License along with this program; if not, write 
 to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 
*/

package ch.justdoit.andriodrpncalc.view;


import android.content.Context;
import android.widget.AbsoluteLayout;
import ch.justdoit.R;
import ch.justdoit.andriodrpncalc.model.Model;
import ch.justdoit.andriodrpncalc.model.command.*;
import ch.justdoit.andriodrpncalc.view.buttons.*;

public class KeySecodaryOp extends AbsoluteLayout{
	private Model model;
	
	public int WIDTH = 106;
	public int HEIGHT = 160;
	
	
	
	public KeySecodaryOp(Context context,  Model _model) {
		super(context);
		model = _model;
		
       int y = 0;
        int x = 0;

        // row 1
		BaseButtonMultifunction btnM1 = new BaseButtonMultifunction(context, model);
		btnM1.registerFirst(new NegCommand(model), R.drawable.btn_neg_ln_e);
		btnM1.registerSecond(new LnCommand(model), R.drawable.btn_ln_neg_e);
		btnM1.registerThird(new eCommand(model), R.drawable.btn_e_ln_neg);
		model.mView.registerThridButtons(btnM1);
		addView(btnM1, 
    			new AbsoluteLayout.LayoutParams(btnM1.WIDTH, btnM1.HEIGHT, x, y)
    	);

		y = y + btnM1.HEIGHT;
		
		// ROW 2
		

		BaseButtonMultifunction btn2 = new BaseButtonMultifunction(context, model);
		btn2.registerFirst(new InvertCommand(model), R.drawable.btn_inv_log_10x);
		btn2.registerSecond(new Log10Command(model), R.drawable.btn_log_inv_10x);
		btn2.registerThird(new NotImplementedCommand(model, "10^x"), R.drawable.btn_10x_log_inv);
		model.mView.registerThridButtons(btn2);
		addView(btn2, 
    			new AbsoluteLayout.LayoutParams(btn2.WIDTH, btn2.HEIGHT, x , y)
    	);
		y = y + btn2.HEIGHT;
		
		// ROW 3
		
		BaseButtonMultifunction btn3 = new BaseButtonMultifunction(context, model);
		btn3.registerFirst(new NotImplementedCommand(model,"x^y"), R.drawable.btn_xy_x2_log1p);
		btn3.registerSecond(new NotImplementedCommand(model, "x^2"), R.drawable.btn_x2_xy_log1p);
		btn3.registerThird(new Log1pCommand(model), R.drawable.btn_log1p_x2_xy);
		model.mView.registerThridButtons(btn3);
		addView(btn3, 
    			new AbsoluteLayout.LayoutParams(btn3.WIDTH, btn3.HEIGHT, x, y)
    	);
		y = y + btn3.HEIGHT;
		
		// ROW 4
		
		
		BaseButtonMultifunction btn4 = new BaseButtonMultifunction(context, model);
		btn4.registerFirst(new SqrtCommand(model), R.drawable.btn_sqrt_xroot_pi);
		btn4.registerSecond(new XrootCommand(model), R.drawable.btn_xroot_sqrt_pi);
		btn4.registerThird(new PiCommand(model), R.drawable.btn_pi_xroot_sqrt);
		model.mView.registerThridButtons(btn4);

		addView(btn4, 
    			new AbsoluteLayout.LayoutParams(btn4.WIDTH, btn4.HEIGHT, x, y)
    	);
		
		y = y + btn4.HEIGHT;
		x = x + btn4.WIDTH;
		WIDTH = x;
		HEIGHT = y;
	}
	
	

}
